package net.xgs.rbac.config;

import com.alibaba.fastjson.JSON;
import net.xgs.rbac.endpoint.RbacEndPoint;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.stream.Collectors;

/**
 * @author xtgss xtgss007@gmail.com
 * @date 2020/3/30 11:04
 */
@Component
public class Runner implements ApplicationRunner {

    private final RbacEndPoint loginEndPoint;

    public Runner(RbacEndPoint loginEndPoint) {
        this.loginEndPoint = loginEndPoint;
    }

    @Override
    public void run(ApplicationArguments args) throws Exception {
        RouteVo mappings = loginEndPoint.mappings();
        System.out.println(JSON.toJSONString(mappings));
        List<String> collect = mappings.stream().map(PathRouteVo::getUrl).collect(Collectors.toList());
        System.out.println(JSON.toJSONString(collect));
    }

}
